package gvalidator

import "regexp"

const (
	AgentKeyPattern   string = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{0,30}[a-zA-Z0-9]{1})$`
	ALPHAPattern      string = `^[a-zA-Z_-]+$`
	DevicePattern     string = `^(desktop|ios|android|harmony)$`
	ALPHANUMERIC      string = `^[a-zA-Z0-9]+$`
	AmountPattern     string = `^(([1-9][0-9]{0,11})|(([0]\.\d{1,18}|[1-9][0-9]{0,11}\.\d{1,18})))$`
	AgentUidPattern   string = `^([a-zA-Z0-9]{1,}[a-zA-Z0-9_-]{0,30}[a-zA-Z0-9]{1,})$`
	AgentUnamePattern string = `^([a-zA-Z0-9]{1,}[a-zA-Z0-9_-]{0,30}[a-zA-Z0-9]{1,})$`
	IntPattern        string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
	NUMERIC           string = "^[-+]?[0-9]+$"
	ALPHANUMERIC1     string = `^[a-zA-Z0-9_.]+$`
)

var (
	reAgentKey      = regexp.MustCompile(AgentKeyPattern)
	reDevice        = regexp.MustCompile(DevicePattern)
	reAlpha         = regexp.MustCompile(ALPHAPattern)
	reAlphaNumeric  = regexp.MustCompile(ALPHANUMERIC)
	reAmount        = regexp.MustCompile(AmountPattern)
	reAgentUid      = regexp.MustCompile(AgentUidPattern)
	reAgentUname    = regexp.MustCompile(AgentUnamePattern)
	reInt           = regexp.MustCompile(IntPattern)
	reNumeric       = regexp.MustCompile(NUMERIC)
	reAlphaNumeric1 = regexp.MustCompile(ALPHANUMERIC1)
)

func DeviceType(device string) int32 {
	switch device {
	case "desktop":
		return 1
	case "ios":
		return 2
	case "android":
		return 3
	case "harmony":
		return 4
	}
	return 0
}
